<?php

namespace app\components;

use app\helpers\Coin;
use Yii;
use yii\di\Instance;

class Language
{
    public $language;

    public function __construct($new_language = 'zh')
    {
        $this->language = $new_language;
    }

    /**
     * @param string $new_language
     * @return mixed|string
     * @throws \yii\base\InvalidConfigException
     */
    public static function getTotal($new_language = 'zh')
    {
        if (!Yii::$container->has(self::class)) {
            Yii::$container->setSingleton(self::class, [
                'class' => self::class,
                'language' => $new_language
            ]);
        }
        /** @var  $instance self */
        $instance = Instance::ensure(self::class);

        return $instance->language;
    }
}
